﻿<form id="org-account-form" lay-filter="org-account-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <input name="state" type="hidden" value="1"/>
    <div class="layui-form-item">
        <label class="layui-form-label">企业名称</label>
        <div class="layui-input-block">
            <input name="name" placeholder="请输入企业名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">企业storeId</label>
        <div class="layui-input-block">
            <input name="storeId" placeholder="请输入企业storeId" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">管理员手机</label>
        <div class="layui-input-block">
            <input name="mobile" placeholder="请输入管理员手机号" type="text" class="layui-input" lay-verify="required|phone"
                   required/>
        </div>
    </div>
    <div  style="display: none">
        <button class="layui-btn" lay-filter="org-account-submit" id = "org-account-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'form', 'formSelects', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var formSelects = layui.formSelects;
        var admin = layui.admin;
        form.render("radio","org-account-form");
        form.render("select","org-account-form");

        var url = 'org/account/add';  // 实际项目这里是添加用户的url
        // 回显user数据
        var account = admin.getTempData('org-account-form-obj');
        if (account) {
            $('#org-account-form input[name="storeId"]').attr('readonly', 'readonly');
            url = 'org/account/update';  // 实际项目这里是修改用户的url
            form.val('org-account-form', account);
        }

        // 表单提交事件
        form.on('submit(org-account-submit)', function (data) {
            admin.req(url, data.field, function (data) {
                layer.msg("保存成功", {icon: 1});
                admin.putTempData('org-account-formOk', true);  // 操作成功刷新表格
                layer.close(layer.curr_idex)
            },"post");
            return false;
        });
    });
</script>

</body>
</html>